home *** CD-ROM | disk | FTP | other *** search
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │index.c │
- │Return the index (pos) of a char in a string or -1 if not found │
- │Usage: │
- │ int result; │
- │ │
- │ if ( (result = index("filename.ext",'.')) == -1) │
- │ printf("No extension was specified"); │
- │ │
- │ (C) JazSoft Software by Jack A. Zucker (301) 794-5950 │
- └────────────────────────────────────────────────────────────────────────────┘
- */
-
- index(s,c)
- char *s,c;
- {
- unsigned int i = (unsigned int) s + 1;
-
- while (*s)
- if (*s++ == c)
- return((unsigned int) s - i);
-
- return(-1);
- }